--- interact_link: content/italy.ipynb kernel_name: python3 kernel_path: content has_widgets: false title: |- Italy pagenum: 2 prev_page: url: /berlin.html next_page: url: /sources.html suffix: .ipynb search: r infected per cases region italy new variation average means person growth epidemic data available daily basis official sources www protezionecivile gov downloaded corresponding repository github com pcm dpc covid relative deaths mortality rate reproduction using simple model en wikipedia org wiki basicreproductionnumber note defined persons subject equal only e linear same amount every less regressing decreases greater indicates exponential comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***" ---
Italy

Italy

Data for italy are available on a daily basis from official sources and can be downloaded from the corresponding repository

import os,sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(''), '../../Code')))
import hedera_covid as hc

# for plotly
from plotly.offline import iplot
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
import plotly as py
import plotly.tools as tls

import datetime
import numpy as np
import pandas as pd


IT = hc.DataHandlerItaly()

all_r = IT.get_all_region_names()


    

new_cases = []

for r in all_r:
    new_cases.append(
        IT.get_plot_data(r, 'nuovi_positivi',n_smooth=7)
        )


deaths = []
for r in all_r:
    deaths.append(
        IT.get_plot_data(r, 'deceduti',n_smooth=7)
        )


tests = []
for r in all_r:
    tests.append(
        IT.get_plot_data(r, 'tamponi',n_smooth=7)
        )

death_rate = []
for r in all_r:
    death_rate.append(
        IT.get_plot_data(r, 'death_rate',n_smooth=7)
        )
    


#hc.plot_structure(new_cases,title="New cases")

#hc.plot_structure(deaths,title="Total deaths")


#hc.plot_structure(tests,title="Tested")


names = ['Lombardia','Veneto','Emilia-Romagna','Piemonte',
         'Liguria', 'Lazio','Toscana','Abruzzo', 'Basilicata', 'Calabria', 'Campania',
         'Friuli Venezia Giulia',   'Marche',
         'Molise', 'P.A. Bolzano', 'P.A. Trento', 'Puglia',
         'Sardegna', 'Sicilia',  'Umbria', "Valle d'Aosta",
       ]

New cases (per region)

import plotly.graph_objects as go
init_notebook_mode(connected=True)



plot_data = []
for r in names:
    region = IT.get_region_by_name(r)
    plot_data.append(
        go.Bar(name=r, x=region['dates'], y=region['nuovi_positivi'])
    )
    

fig = go.Figure(data=plot_data)

# Change the bar mode
fig.update_layout(barmode='stack')
    
fig.update_layout(xaxis_tickangle=-90)
#fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Relative variation

Variation of cases (%) per region

import plotly.graph_objects as go
init_notebook_mode(connected=True)

relative_variation = []
for r in all_r:
    region = IT.get_region_by_name(r)
    p = np.array(region['totale_casi'])
    v = []
    v.append(0.)
    for k in range(1,len(p)):
        if p[k-1]<=10:
            v.append(0.)
        else:
            tmp = 100*( p[k] - p[k-1] ) / p[k-1]
            v.append(round( tmp,2 ))
    plot_data = {
        "type": 'scatter',
        "name": r,
        "x": region['dates'],
        "y": hc.smooth_data(v,n=7)
    }
    relative_variation.append(plot_data)
    
fig = {
    "data": relative_variation
    }
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Deaths per day per region

import plotly.graph_objects as go
init_notebook_mode(connected=True)



plot_data = []
for r in names:
    region = IT.get_region_by_name(r)
    plot_data.append(
        go.Bar(name=r, x=region['dates'], y=region['deceduti'])
    )
    

fig = go.Figure(data=plot_data)

# Change the bar mode
fig.update_layout(barmode='stack')
    
fig.update_layout(xaxis_tickangle=-90)
#fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
import plotly.graph_objects as go
init_notebook_mode(connected=True)


names = ['Lombardia','Veneto','Emilia-Romagna','Piemonte',
         'Abruzzo', 'Basilicata', 'Calabria', 'Campania',
         'Friuli Venezia Giulia', 'Lazio', 'Liguria', 'Marche',
         'Molise', 'P.A. Bolzano', 'P.A. Trento', 'Puglia',
         'Sardegna', 'Sicilia', 'Toscana', 'Umbria', "Valle d'Aosta",
       ]
plot_data = []
for r in names:
    region = IT.get_region_by_name(r)
    nuovi_deceduti = []
    nuovi_deceduti.append(0.)
    p = np.array(region['deceduti'])
    for k in range(1,len(p)):
        nuovi_deceduti.append( (p[k]-p[k-1]))
    
    plot_data.append(
        go.Bar(name=r, x=region['dates'], y=hc.smooth_data(nuovi_deceduti,n=7))
    )
    

fig = go.Figure(data=plot_data)

# Change the bar mode
fig.update_layout(barmode='stack')
    
fig.update_layout(xaxis_tickangle=-90)
#fig.update_layout(legend=dict(x=0.1, y=1.2),legend_orientation="h",font_size=10)

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Mortality Rate

import plotly.graph_objects as go
init_notebook_mode(connected=True)

fig = {
    "data": death_rate,
    "layout": {"title": {"text": ""}}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

R0

Reproduction number R0 using a simple model.

Note R0 is defined as the average number of persons infected by an infected subject.

  • R0 equal to one means that, on average, each infected person has infected only one person, i.e., that the growth of the epidemic is linear (same amount of new cases every day).

  • R0 less than one means that the epidemic is regressing (the number of infected decreases)

  • R0 greater than one indicates exponential growth.

import plotly.graph_objects as go
init_notebook_mode(connected=True)

R0 = []
for r in all_r:
    R0.append(
        IT.get_plot_data(r, 'R0',n_smooth=0)
        )


    
fig = {
    "data": R0,
    "layout": {"title": {"text": ""}}
}



plot(fig, filename = 'figure.html')
display(HTML('figure.html'))